<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Redo extends Model
{
    use HasFactory;

    protected $fillable = ['user_id', 'question_id', 'type'];

    public $timestamps = false;

    /**
     * 和用户的关联
     *
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function user()
    {
        return $this->belongsTo(User::class, 'user_id', 'id');
    }

    /**
     * 和题目的关联
     *
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
     */
    public function question()
    {
        return $this->hasOne(Question::class, 'id', 'question_id');
    }

//    protected static function booted()
//    {
//        static::created(function ($model) {
//            $model->user_id = auth()->id();
//
//            $model->save();
//        });
//
//    }
}
